package cn.hfatec.shms.utils;

import cn.hfatec.app.AppContext;
import cn.hfatec.shms.enums.KeyTypeEnum;
import cn.hfatec.shms.exception.KeyGenException;
import cn.hfatec.shms.system.keyGenerator.dao.KeyGeneratorDao;
import org.springframework.transaction.annotation.Transactional;

/**
 *
 * 自增主键工具类
 *
 * @author: panwb
 *
 * Date: 2015/11/8
 * Time: 21:11
 */
public class KeyGenUtils {

    /**
     *
     * 根据自增主键类型获取自增主键
     *
     * @param keyType
     * @return
     */
    @Transactional
    public static String createKeyByType(KeyTypeEnum keyType) throws KeyGenException {
        KeyGeneratorDao keyGeneratorDao = AppContext.getBean(KeyGeneratorDao.class);
        return keyGeneratorDao.getKeyGeneratorByType(keyType.name());
    }
}
